package com.shengzai.mapreduce.studentjoin;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;


public class ReduceStudentJoin extends Reducer<Text,Text, Text,Text> {
    @Override
    protected void reduce(Text key, Iterable<Text> values, Reducer<Text, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        String stuInfo=null;
        String stuScore = null;
        for (Text value : values) {
            String s = value.toString();
            if(s.contains(",")){
                stuInfo = s;
            }else {
                stuScore=s;
            }
        }
        context.write(key,new Text(stuInfo+","+stuScore));
    }
}
